package com.dart.sys.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.dart.commons.base.web.BaseController;
import com.dart.framework.annotations.Log;
import com.dart.sys.entity.AppGlable;
import com.dart.sys.service.AppGlableService;
import com.github.pagehelper.PageInfo;

@RestController
@RequestMapping("/sys/app")
public class AppGlableController extends BaseController {
	
	@Autowired
	private AppGlableService service ;
	
	@Log("新增全局信息")
	@RequestMapping(value="/add", method=RequestMethod.POST)
	public Object add(AppGlable entity, HttpServletRequest request, ModelMap modelMap) {
		if(this.service.insertSelective(entity)) {
			return setAjaxMapSuccess();
		} else {
			return setAjaxMapFailed();
		}
	}
	
	@Log("删除全局信息")
	@RequestMapping(value="/delete/{id}", method=RequestMethod.GET)
	public Object delete(@PathVariable Integer id) {
		if(this.service.delete(id)) {
			return setAjaxMapSuccess();
		} else {
			return setAjaxMapFailed();
		}
	}
	
	@Log("修改全局信息")
	@RequestMapping(value="/update", method=RequestMethod.POST)
	public Object update(AppGlable entity) {
		if(this.service.updateSelective(entity)) {
			return setAjaxMapSuccess();
		} else {
			return setAjaxMapFailed();
		}
	}
	
	@Log("根据ID查询全局信息")
	@RequestMapping(value="/get/{id}", method=RequestMethod.GET)
	public Object get(@PathVariable Integer id) {
		AppGlable entity = this.service.selectById(id) ;
		if(null != entity) {
			return setAjaxMapSuccess(entity) ;
		} else {
			return setAjaxMapFailed();
		}
	}
	
	@Log("查询全局信息")
	@RequestMapping(value="/list", method=RequestMethod.GET)
	public Object list(AppGlable entity) {
		PageInfo<AppGlable> selectPage = this.service.selectPage(entity) ;
		if(null != selectPage) {
			return setAjaxMapSuccess(selectPage) ;
		} else {
			return setAjaxMapFailed();
		}
	}
	
	
}
